from logicaltool.sqltools.two_table_contrast import TableContrast
from xjlibrary.our_file_dir import BaseDir


class TableContrast2(TableContrast):
    def __init__(self):
        super().__init__()
        self.sqlconn1 = self.mysqlconn(BaseDir.get_new_path(BaseDir.get_file_dir_absolute(__file__), "db.ini"), "db1")
        self.sqlconn2 = self.sqlite3conn(r"C:\Users\xuzhu\Desktop\zlf_bz.db3")
        self.inputobj1 = set()
        self.inputobj2 = set()
        self.ouputobj1 = set()

    def get_one_table_data(self):
        sql = self.one_table_data_hook()
        rows = self.sqlconn1.ExeSqlToDB(sql)

    def one_table_data_hook(self):
        sql = "update articlenew set stat=2 where standardid in {}".format(tuple(self.inputobj2))
        return sql

    def get_other_table_data(self):
        sql = self.other_table_data_hook()
        rows = self.sqlconn2.SelectFromSqlliteFetchall(sql)
        for row in rows:
            self.inputobj2.add(row[0].replace("W_CG_",""))

    def other_table_data_hook(self):
        sql = "select rawid from modify_title_info"
        return sql

    def deal_data(self):
        # self.get_one_table_data()
        self.get_other_table_data()
        self.get_one_table_data()
        # sql = "insert ignore into articlenew (`standardid`) values (%s)"
        # self.sqlconn1.ExeSqlMany(sql, self.inputobj1)
        # print(len(self.inputobj2))
        #
        # print(len(self.inputobj1))
        # print(len(self.inputobj2-self.inputobj1))
        # print(self.inputobj2-self.inputobj1)


tables2 = TableContrast2()
dicts2 = tables2.deal_data()
print("dicts2 完成")
